<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Oboe: oboe::ResultWithValue&lt; T &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Oboe
   &#160;<span id="projectnumber">1.2</span>
   </div>
   <div id="projectbrief">A library for creating real-time audio apps on Android</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceoboe.html">oboe</a></li><li class="navelem"><a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="classoboe_1_1_result_with_value-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">oboe::ResultWithValue&lt; T &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;<a class="el" href="_result_with_value_8h_source.html">ResultWithValue.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:aae75caa0d16a9e23a012f77fb50c5927"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#aae75caa0d16a9e23a012f77fb50c5927">ResultWithValue</a> (<a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">oboe::Result</a> <a class="el" href="classoboe_1_1_result_with_value.html#adfc76ae6db81535c2e82b856975eed41">error</a>)</td></tr>
<tr class="separator:aae75caa0d16a9e23a012f77fb50c5927"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a600309367db58d71f0ec16e90f7ebea5"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#a600309367db58d71f0ec16e90f7ebea5">ResultWithValue</a> (T <a class="el" href="classoboe_1_1_result_with_value.html#a45f5c99a2c9f8fbaca502276f7ebb434">value</a>)</td></tr>
<tr class="separator:a600309367db58d71f0ec16e90f7ebea5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adfc76ae6db81535c2e82b856975eed41"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">oboe::Result</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#adfc76ae6db81535c2e82b856975eed41">error</a> () const</td></tr>
<tr class="separator:adfc76ae6db81535c2e82b856975eed41"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a45f5c99a2c9f8fbaca502276f7ebb434"><td class="memItemLeft" align="right" valign="top">T&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#a45f5c99a2c9f8fbaca502276f7ebb434">value</a> () const</td></tr>
<tr class="separator:a45f5c99a2c9f8fbaca502276f7ebb434"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae32b1953b777af7d1d0c94862ca39986"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#ae32b1953b777af7d1d0c94862ca39986">operator bool</a> () const</td></tr>
<tr class="separator:ae32b1953b777af7d1d0c94862ca39986"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6fb3c61c5716a045ba48dc5a5dfc8169"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#a6fb3c61c5716a045ba48dc5a5dfc8169">operator !</a> () const</td></tr>
<tr class="separator:a6fb3c61c5716a045ba48dc5a5dfc8169"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af62107817c0bc76047e6b655a78504ba"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#af62107817c0bc76047e6b655a78504ba">operator Result</a> () const</td></tr>
<tr class="separator:af62107817c0bc76047e6b655a78504ba"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:a2304c6120e2aad8f2189383a98c7b0a7"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a>&lt; T &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#a2304c6120e2aad8f2189383a98c7b0a7">createBasedOnSign</a> (T numericResult)</td></tr>
<tr class="separator:a2304c6120e2aad8f2189383a98c7b0a7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename T&gt;<br />
class oboe::ResultWithValue&lt; T &gt;</h3>

<p>A <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> can store both the result of an operation (either OK or an error) and a value.</p>
<p>It has been designed for cases where the caller needs to know whether an operation succeeded and, if it did, a value which was obtained during the operation.</p>
<p>For example, when reading from a stream the caller needs to know the result of the read operation and, if it was successful, how many frames were read. Note that <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> can be evaluated as a boolean so it's simple to check whether the result is OK.</p>
<p><code> ResultWithValue&lt;int32_t&gt; resultOfRead = myStream.read(&amp;buffer, numFrames, timeoutNanoseconds);</code></p>
<p><code>if (resultOfRead) { LOGD("Frames read: %d", resultOfRead.value()); } else { LOGD("Error reading from stream: %s", resultOfRead.error()); } </code> </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="aae75caa0d16a9e23a012f77fb50c5927"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aae75caa0d16a9e23a012f77fb50c5927">&#9670;&nbsp;</a></span>ResultWithValue() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::<a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">oboe::Result</a>&#160;</td>
          <td class="paramname"><em>error</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Construct a <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> containing an error result.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">error</td><td>The error </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a600309367db58d71f0ec16e90f7ebea5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a600309367db58d71f0ec16e90f7ebea5">&#9670;&nbsp;</a></span>ResultWithValue() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::<a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> </td>
          <td>(</td>
          <td class="paramtype">T&#160;</td>
          <td class="paramname"><em>value</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Construct a <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> containing an OK result and a value.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">value</td><td>the value to store </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a2304c6120e2aad8f2189383a98c7b0a7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2304c6120e2aad8f2189383a98c7b0a7">&#9670;&nbsp;</a></span>createBasedOnSign()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a>&lt;T&gt; <a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::createBasedOnSign </td>
          <td>(</td>
          <td class="paramtype">T&#160;</td>
          <td class="paramname"><em>numericResult</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Create a <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> from a number. If the number is positive the <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> will have a result of Result::OK and the value will contain the number. If the number is negative the result will be obtained from the negative number (numeric error codes can be found in AAudio.h) and the value will be null. </p>

</div>
</div>
<a id="adfc76ae6db81535c2e82b856975eed41"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adfc76ae6db81535c2e82b856975eed41">&#9670;&nbsp;</a></span>error()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">oboe::Result</a> <a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::error </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Get the result.</p>
<dl class="section return"><dt>Returns</dt><dd>the result </dd></dl>

</div>
</div>
<a id="a6fb3c61c5716a045ba48dc5a5dfc8169"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6fb3c61c5716a045ba48dc5a5dfc8169">&#9670;&nbsp;</a></span>operator !()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::operator ! </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Quick way to check for an error.</p>
<p>The caller could write something like this: <code> if (!result) { printf("Got error %s\n", convertToText(result.error())); } </code></p>
<dl class="section return"><dt>Returns</dt><dd>true if an error occurred </dd></dl>

</div>
</div>
<a id="ae32b1953b777af7d1d0c94862ca39986"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae32b1953b777af7d1d0c94862ca39986">&#9670;&nbsp;</a></span>operator bool()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::operator bool </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>true if OK </dd></dl>

</div>
</div>
<a id="af62107817c0bc76047e6b655a78504ba"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af62107817c0bc76047e6b655a78504ba">&#9670;&nbsp;</a></span>operator Result()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::operator <a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">Result</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Implicitly convert to a Result. This enables easy comparison with Result values. Example:</p>
<p><code> <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> result = openStream(); if (result == Result::ErrorNoMemory){ // tell user they're out of memory } </code> </p>

</div>
</div>
<a id="a45f5c99a2c9f8fbaca502276f7ebb434"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a45f5c99a2c9f8fbaca502276f7ebb434">&#9670;&nbsp;</a></span>value()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">T <a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::value </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Get the value </p><dl class="section return"><dt>Returns</dt><dd></dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>include/oboe/<a class="el" href="_result_with_value_8h_source.html">ResultWithValue.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.15
</small></address>
</body>
</html>
